local joy__yuma = fk.CreateSkill {

  name = "joy__yuma",

  tags = { Skill.Compulsory, },

}



joy__yuma:addEffect(fk.AfterCardsMove, {
  name = "joy__yuma",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.AfterCardsMove},
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(joy__yuma.name) then return end
    for _, move in ipairs(data) do
      if move.from==player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip and (Fk:getCardById(info.cardId).sub_type == Card.SubtypeDefensiveRide or Fk:getCardById(info.cardId).sub_type == Card.SubtypeOffensiveRide) then
            return true
          end
        end
      end
    end
  end,
  on_trigger = function(self, event, target, player, data)
    local n = 0
    for _, move in ipairs(data) do
      if move.from==player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerEquip and (Fk:getCardById(info.cardId).sub_type == Card.SubtypeDefensiveRide or Fk:getCardById(info.cardId).sub_type == Card.SubtypeOffensiveRide) then
            n = n + 1
          end
        end
      end
    end
    for _ = 1, n do
      if  not player:hasSkill(joy__yuma.name) then break end
      self:doCost(event, target, player, data)
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(2, joy__yuma.name)
  end,
})

joy__yuma:addEffect("distance", {
  name = "#joy__yuma_distance",
  correct_func = function(self, from, to)
    if from:hasSkill(joy__yuma) then
      return -1
    end
  end,
})

return joy__yuma